package org.epidroid.epidroid.chronos.engine.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.epidroid.epidroid.chronos.engine.objects.Printable;

public class ChronosUtils {

	public static void printIndent(Integer indent) {
		for (int i = 0; i < indent; ++i) {
			if (i % 4 == 0)
				System.out.print("|");
			else
				System.out.print(" ");
		}
	}

	public static void printWithIndent(Integer indent, String toPrint) {
		ChronosUtils.printIndent(indent);
		System.out.println(toPrint);
	}

	public static void print(Printable o) {
		o.print(0);
	}

	public static Date parseDate(String date) {
		DateFormat formatter = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
		try {
			return formatter.parse(date);
		} catch (ParseException e) {
			return null;
		}
	}

	public static String formatDateDigitsNoTime(Date date) {
		DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
		return formatter.format(date);
	}

	public static String formatDateDigits(Date date) {
		DateFormat formatter = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
		return formatter.format(date);
	}

	public static String formatDateTextNoTime(Date date) {
		return new SimpleDateFormat("E, MMM dd, yyyy").format(date);
	}

}
